/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 dialog_file.h (file_dialog)

	$Header: /resource_editor/dialog_file.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined(DIALOG_FILE_H_INCLUDED)
#define DIALOG_FILE_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "bitmap_group_ptr.h"
#include "button_group.h"
#include "game_window.h"
#include "saved_game_header.h"

class t_button;
class t_scrollbar;
class t_text_window;
class t_toggle_button;

// ------------------------------------------------------------------
// base class for save game and load game dialogs.
// ------------------------------------------------------------------
struct t_file_dialog_data
{
	bool				is_folder;
	std::string			file_name;
	long				file_time;
	t_saved_game_header header;
};

class t_dialog_file : public t_window
{
public:
	typedef t_file_dialog_data t_file_data;
protected:
	t_dialog_file( t_bitmap_group_ptr bitmaps, t_window* parent );

	void		 cancel_click( t_button* );
	void		 create_buttons( t_window* parent, t_screen_point origin );
	void		 create_title( std::string const& title );
	void		 double_click( t_button* button, int line );
	void		 file_scroll( t_scrollbar* scrollbar, int line );
	void		 file_selected( t_button*, int line );
	virtual void finish() = 0;
	void		 read_directory( std::string const& name );
	virtual void select_file( t_file_data& data ) = 0;

	struct t_file_button
	{
		t_toggle_button* button;
		t_text_window*   file_name;
		t_text_window*   highlighted_file_name;
		t_text_window*   file_time;
		t_text_window*   highlighted_file_time;
	};

	t_window*                           m_background;
	t_screen_point                      m_background_origin;
	t_bitmap_group_ptr					m_bitmaps;
	t_button_group						m_button_group;	  // controls radio button effects
	t_button*							m_cancel_button;
	std::vector<t_file_button>			m_file_buttons;
	std::vector<t_file_data>			m_files;
	std::string							m_folder;			  // current working folder
	t_scrollbar*						m_scrollbar;
	int									m_selected_item;     // currently selected file
	int									m_top_line;          // first visible line
};

#endif // DIALOG_FILE_H_INCLUDED